package com.review.reviewsb;

import java.sql.*;

/**
 * @program: reviewSb
 * @description: 测试原生
 * @author: YaoZhiLi
 * @create: 2021-07-06 22:25
 */
public class JdbcApp {
    public static void main(String[] args) throws Exception {
    /*加载JDBC驱动程序
    创建数据库的连接
    创建preparedStatement
    执行SQL语句
    处理结果集
    关闭JDBC对象资源*/
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false";
        String username = "root";
        String password = "123456";
        Connection connection = DriverManager.getConnection(url, username, password);
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from video");
        while (resultSet.next()){
            System.out.println("视频标题："+resultSet.getString("title"));
        }
        statement.close();
    }
}